1. Field of the Invention
The present invention relates to a nonvolatile memory system using a nonvolatile memory device having a rewritable nonvolatile memory as a storage medium, nonvolatile memory device, memory controller, access device, and method for controlling the nonvolatile memory device.
2. Discussion of the Related Art
A nonvolatile memory device having a rewritable nonvolatile memory, mainly a semiconductor memory card, has been widely demanded. A nonvolatile memory system using the semiconductor memory card, mainly a digital still camera, has been also widely demanded. A NAND flash memory, a nonvolatile memory, mainly used in the semiconductor memory card adopts an erase unit of 16 KB (byte). An access device using the semiconductor memory card adopts 16 KB as a write management unit, that is, a cluster capacity as an area allocation unit of file data.
In recent years, however, the nonvolatile memory system has expanded its application range as a recording/reproducing system of stream data such as moving images as well as text data and still images. Along with its application, a large-capacity flash memory which can record moving images in sufficient time has been desired. Cost reduction has been also desired. In response to the desires, a NAND flash memory adopting an erase unit of 128 KB or 256 KB has been proposed. However, a memory controller in the nonvolatile memory device handles write in units of 16 KB from the access device as write in units of 128 KB or 256 KB being the erase unit of the NAND flash memory. Therefore, it takes longer time for write in units of 16 KB relatively, seen from the access device.
A file system managing data stored in the nonvolatile memory device will be described here. The file system is a system which can easily handle data stored in the nonvolatile memory device as a file. As file systems which have been conventionally used, there exist a FAT file system (ISO/IEC9293, “Information Technology-Volume and file structure of disk cartridges for information”, 1994), UDF (Universal Disk Format) (OSTA Universal Disk Format Specification Revision 1.50, 1997), and NTFS (New Technology File System). The nonvolatile memory device in which data is managed by these file systems can share file data among devices interpreting the same file system, therefore, the data can be transmitted/received among the devices. The file system prorates an information record area in which data are recorded into sectors as the minimum access unit and clusters as an assembly of sectors to manage them and manages one or more clusters as a file.
The FAT file system and a conventional nonvolatile memory system using the FAT file system will be described more specifically. FIG. 1 shows the configuration of the FAT file system. A file system management area 600 of FIG. 1 refers to the area of a nonvolatile memory managed by a file system, seen from the access device side of the nonvolatile memory system and corresponds to all areas or some areas described as user data. LA denotes a logical address, which has logical address number from 0 to M-1. In the FAT file system, a management information area 601 for managing the entire file system management area exists at the head of the file system management area, continuously a data area 602 storing data in a file exists. The management information area 601 is configured with a master boot record-partition table (MBR-PT) 603, partition boot sector (PBS) 604, FATs 605 and 606, and root directory entry (RDE) 607.
The MBR-PT 603 is a part for storing information for dividing the file system management area into a plurality of areas called partition to manage them. The PBS 604 is a part for storing management information in one partition. The FATs 605 and 606 are parts for indicating the physical storage position of data included in a file. The RDE 607 is a part for storing information of files and directories existing immediately below a root directory. Because the FAT is an important area indicating the physical storage position of data included in a file, the FATs 605 and 606 having two pieces of identical information generally exist in the file system management area and are duplexed.
The data area 602 consists of a plurality of clusters, and each cluster stores data included in a file. A file storing much data stores the data across the plurality of clusters, and a connection between the clusters is shown by link information stored in the FATs 605 and 606. A data storing example in the FAT file system will be described using FIG. 2. The data area 602 consists of fixed length block units called clusters, and each cluster has a cluster number in ascending order starting from 2. The FATs 605 and 606 manage the utilization status of each cluster and link information showing a connection between the clusters and have a FAT entry corresponding to each cluster number. The FAT entry has any one of three sizes of 12 bits, 16 bits, and 32 bits per cluster depending on the type of the FAT file system. In the example of FIG. 2, a case is shown that one entry is expressed by 16 bits. The FAT entry stores any one value of the cluster number of the next linked cluster, 0x0000 indicating that the cluster is a space area or 0xFFFF indicating that the cluster is link terminal. The example of FIG. 2 shows that the FAT entries corresponding to the cluster numbers 2, 5, and 7 store 0x0000 and the three clusters are space areas. The FAT entry corresponding to the cluster number 3 stores 0x0004, the FAT entry corresponding to the cluster number 4 stores 0x0006, and the FAT entry corresponding to the cluster number 6 stores 0xFFFF. The three clusters of the cluster numbers 3, 4, and 6 show that divided data is stored.
A file data write example in the FAT file system will be described using FIGS. 3 to 5C. FIG. 3 show a file data write process procedure in the FAT file system. FIGS. 4A to 4C show an example of a directory, the FATs 605 and 606 and the data area 602 respectively before the write process, and FIG. 5A to 5C show the example of them after the write process. In the FAT file system, the root directory entry 607 or part of the data area 602 stores a directory entry which has stored information such as a file name, file size, and file attribute. FIG. 4A shows an example of the directory entry. A file indicated by the directory entry has a file name represented as FILE1.TXT, data of the file are stored in clusters starting from the cluster number 10, and file size is 16 KB. In FIG. 4C, the size of one cluster is assumed to be 4096 bytes and the file data is stored across four clusters.
The file data write process will be described using FIG. 3. At first, the file data write process reads the directory entry of a target file (S801). Next, the file start cluster number stored in the read directory entry is obtained, and the head position of file data is checked (S802). Next, the FATs 605 and 606 are read to trace the link on the FATs 605 and 606 sequentially from the head position of the file data obtained in S802, and the cluster number in the write position is obtained (S803). Next, in writing data, it is determined whether a space area needs to be allocated to the file (S804). When the space area allocation is unnecessary, the routine is advanced to the process of S806. When the space area allocation is necessary, a space area is searched on the FATs 605 and 606, and a space area of one cluster is allocated to the termination of the file (S805). Next, the maximum amount of data that can be written into the currently referred cluster is written into the data area 602 (S806). Next, it is determined whether the data write of all data has been completed (S807). When there is remaining data, the routine is returned to the process of S804. When the data write of all data has been completed, the file size and time stamp stored in the directory entry are updated and are written into the nonvolatile memory device (S808). Finally, the FATs 605 and 606 are written into the nonvolatile memory device to complete the process (S809).
When the file data write process additionally writes data of 1 KB into FILE1.TXT having data of 16 KB shown in FIG. 4A, the file is changed to a file having data of 17 KB shown in FIG. 5A. As described above, the FAT file system performs allocation in units of clusters for a file data storage area and data are stored.
FIG. 6 is a block diagram of the conventional nonvolatile memory system. In FIG. 6, the nonvolatile memory system consists of a nonvolatile memory device 101 and access device 102. The nonvolatile memory device 101 includes a memory controller 103 and nonvolatile main memory 104. The memory controller 103 includes a host interface 111 (the interface is described as I/F in the drawings), CPU 112, RAM 113, ROM 114, and control part 115. The host interface 111 is an interface transmitting/receiving various commands, logical address, and data to/from the access device 102. The ROM 114 stores a program controlling the entire memory controller 103. The program uses the RAM 113 as a temporary storage area and is operated on the CPU 112. The control part 115 is a circuit controlling the main memory 104 as the data storage area in the nonvolatile memory device 101. The control part 115 includes an address managing part 116 managing the address of the main memory and main memory access part 117.
In FIG. 6, the access device 102 accesses the nonvolatile memory device 101 and includes a CPU 121, RAM 122, ROM 123, and slot 124. The ROM 123 stores a program controlling the access device 102. The program uses the RAM 122 as a temporary storage area and is operated on the CPU 121. The slot 124 is a connection part of the nonvolatile memory device 101 and the access device 102. The access device 102 transmits/receives various commands, logical address, and data to/from the nonvolatile memory device 101 via the slot 124. Further, the ROM 123 includes an application program 125, file system control part 126, and access control part 127.
FIG. 7 is a block diagram showing the address managing part 116. The address managing part 116 includes an address converting table 132, physical area managing table 133, and table access part 131.
FIG. 8A is an explanatory view showing a physical block of the nonvolatile main memory 104 and is an example in which physical block size is 16 KB. In FIG. 8A, each physical block consists of 32 pages having page addresses 0 to 31. Each of the pages consists of a data area (512 bytes) for one sector indicated by hatching and a management area (16 bytes).
FIG. 8B is an example in which physical block size is 128 KB. In FIG. 8B, each physical block consists of 128 pages having page addresses 0 to 127. Each of the pages consists of a data area of four sectors (2048 bytes) and a management area (64 bytes). One sector indicated by hatching has an area of 512 bytes. In-page arrangement numbers 0 to 3 are given to four sectors of each of the pages.
FIG. 9A is an explanatory view showing the format of logical block address LBA that the access device 102 specifies to the nonvolatile memory device 101 when the physical block size of the nonvolatile main memory 104 is 16 KB. In FIG. 9A, sector numbers and cluster numbers are shown sequentially from the low-order bit. In the description below, explanation on the basis that cluster size is 16 KB will be done. The address converting table 132 converts the cluster numbers b19 to b5 to 32768 physical block addresses PBA in the main memory 104. Other bits are used as the page addresses of 32 pages in the physical block.
FIG. 9B is an explanatory view showing the format of the logical block address LBA that the access device 102 specifies to the nonvolatile memory device 101 when the physical block size of the nonvolatile main memory 104 is 128 KB. In FIG. 9B, sector numbers and cluster numbers are shown sequentially from the low-order bit, and the address converting table 132 converts b19 to b9 to 2048 physical block addresses PBA in the main memory 104. Bits b8 to b2 correspond to the page addresses of 128 pages in the physical block. Bits b1 to b0 correspond to in-page arrangement numbers. The main memory 104 has a capacity of 2 G bit (256 MB).
FIG. 10A is an explanatory view showing the physical management area table 133 when the physical block size of the main memory 104 is 16 KB, and FIG. 10B is an explanatory view when the physical block size of the main memory 104 is 128 KB. In FIGS. 10A and 10B, the address of the physical area managing table 133 corresponds to the physical block address PBA of the main memory 104 and the status of each physical block, that is, the block status is stored by 2 bits. In binary, the value 00 indicates a valid block in which valid data is stored, the value 01 indicates an unnecessary invalid block in which data is written, the value 10 indicates a bad block which cannot be used due to a solid error on a memory cell, and the value 11 indicates an erased block.
FIG. 11A is an explanatory view showing an address converting table 132 when physical block size of the main memory 104 is 16 KB, and FIG. 11B is an explanatory view showing the address converting table 132 when physical block size of the main memory 104 is 128 KB. In FIGS. 11A and 11B, the physical block address PBA is stored in the address converting table 132 corresponding to the logical address LBA specified by the access device 102, that is, b19 to b5 of the logical block address LBA shown in FIG. 9A or b19 to b9 of the logical block address LBA shown in FIG. 9B.
The operation of the conventional nonvolatile memory system will be described. The access device 102 configures logical address arrangement shown in (a) of FIG. 12 by formatting the nonvolatile memory device 101 based on the FAT file system. In FIG. 12, the MBR-PT 603 adjusts the size of a management information area 601 consisting of PBS 604, FATs 1 and 2, and RDE 607 and sets them to be the multiple length of cluster size. In FIG. 12, (b) and (c) show the main memory 104 storing the contents of the logical addresses. In FIG. 12, (b) shows arrangement in the case of 16 KB being the size of an erase unit, that is, physical block PB, and (c) shows arrangement in the case of 128 KB being the size of the physical block PB. In either case, the data area 602 shown in FIG. 1, that is, the area starting from the cluster #2 of the logical address arrangement of (a) of FIG. 12 is matched with the boundary of the physical block PB.
In the initializing process, the CPU 112 reads address management information 118 of the main memory 104 via a main memory access part 117, and configures the address converting table 132 and the physical area managing table 133 shown in FIG. 7. The description of other initializing processes is omitted.
After such format and initialization, the access device 102 starts accessing the main memory 104. Its operation will be described below by taking a write process as an example. The access control part 127 in the access device 102 sends out a write instruction to the file system control part 126. The file system control part 126 searches a space area based on the FATs 605 and 606 shown in FIG. 1, and, when a space area exists, writes data into the obtained space area. At this time, the access device 102 transfers write command WCMD, predetermined logical address, and data to the nonvolatile memory device 101. In the nonvolatile memory device 101, the CPU 112 identifies the write command WCMD and transfers control to the control part 115. In the control part 115, the address managing part 116 decides a target physical address for data write based on the logical address transferred by the access device 102. In the address managing part 116, the table access part 131 shown in FIG. 7 searches an erased physical block based on the physical area managing table 133 to specify the physical block to a block to be written. Further, the table access part 131 writes the physical block address PBA being the block to be written in a predetermined logical address position of the address converting table 132. In searching the erased physical block of the table access part 131, a search function considering wear leveling is generally provided so as not to concentrate write or erase on a specific physical block.